package com.eupmt.lab3.persistence.ibatis.dao;

import com.eupmt.lab3.domain.BoGarantia;
import com.eupmt.lab3.domain.Client;
import com.eupmt.lab3.domain.Producte;
import com.ibatis.common.resources.Resources;
import com.ibatis.dao.client.DaoManager;
import com.ibatis.dao.client.DaoManagerBuilder;
import java.io.IOException;
import java.io.Reader;
import java.util.List;

/**
 *
 * @author sony
 */
public class BoGarantiaDaoManager extends DAOManager {
    
    
    
   protected static BoGarantiaDaoManager instance = null;
    private BoGarantiaDAO boGarantiaDAO = null;

    private BoGarantiaDaoManager() throws IOException {
        super();
        Reader readerDao = Resources.getResourceAsReader("com/eupmt/lab3/persistence/ibatis/daoConfig.xml");
        DaoManager daoManager = DaoManagerBuilder.buildDaoManager(readerDao);
        this.boGarantiaDAO = (BoGarantiaDAO) daoManager.getDao(BoGarantiaDAO.class);
//        clientDAO = new ClientDAOImpl();
    }

   public void saveBoGarantia(BoGarantia boGarantia)   throws Exception{
        boGarantiaDAO.saveBoGarantia(boGarantia);
   }

   public void insertBoGarantia(BoGarantia boGarantia) throws Exception{
       boGarantiaDAO.insertBoGarantia(boGarantia);

   }
   public void updateBoGarantia(BoGarantia boGarantia) throws Exception{
       boGarantiaDAO.updateBoGarantia(boGarantia);
   }
   public void deleteBoGarantia(BoGarantia boGarantia) throws Exception{
       boGarantiaDAO.deleteBoGarantia(boGarantia);
   }

   public BoGarantia getBoGarantiaById(int idBoGarantia)        throws Exception{
       return boGarantiaDAO.getBoGarantiaById(idBoGarantia);
   }
   public List<BoGarantia> getBonsGarantiaByClient(Client client)       throws Exception{
       return boGarantiaDAO.getBonsGarantiaByClient(client);
   }
   public List<BoGarantia> getBonsGarantiaByProducte(Producte producte) throws Exception{
        return boGarantiaDAO.getBonsGarantiaByProducte(producte);
   }

   public static BoGarantiaDaoManager getInstance() throws IOException {
        if (instance == null) {
            instance = new BoGarantiaDaoManager();
        }
        return instance;
    }


}
